package com.example.book.controller;


import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("/user")
@RestController
public class UserController {
    @RequestMapping("/login")
    public String login(String username, String password, HttpSession session) {
        if(!StringUtils.hasLength(username) || !StringUtils.hasLength(password)){
            return "账号或密码为空";
        }
        if(!"admin".equals(username) || !"123456".equals(password)){
            return "账号或密码错误";
        }
        session.setAttribute("username", username);
        return "success";

    }
}
